﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls;
using System.Net.Mail;

public partial class senha : System.Web.UI.Page {

    protected void Page_Load(object sender, EventArgs e) {

    }
    protected void btnRecuperarSenha_Click(object sender, EventArgs e) {
        
        PetShopService.Usuario oUsuario = new PetShopService.Usuario();
        PetShopService.UsuarioServicos usuarioServices = new PetShopService.UsuarioServicos();
        string email = txtEmail.Text;
        oUsuario = usuarioServices.RetornaUsuario(email);
        if (oUsuario == null) {
            lblReposta.Text = "Email não econtrado";
            return;
        }

        MailMessage mail = new MailMessage("you@yourcompany.com", email);
        SmtpClient client = new SmtpClient();
        client.Port = 25;
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.UseDefaultCredentials = false;
        client.Host = "smtp.google.com";
        mail.Subject = "Recuperação de senha";
        mail.Body = "Sua senha é " + oUsuario.senha;
        client.Send(mail);
        lblReposta.Text = "Sua senha foi enviada";
    }
}